﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RestaurateurConsole.Core;

namespace RestaurateurConsole
{
    class HandlerFactory
    {
        DataEncapsulator dataEncapsulator;
        DishesHandler dishesHandler;
        SoldItemsHandler soldItemsHandler;
        SalesHandler salesHandler;
        CustomerHandler customerHandler;
        ActivityHandler activityHandler;
        public static SerializationHandler serializer = new SerializationHandler( Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Restaurateur", "RestaurateurMenu.menu");

        public HandlerFactory()
        {
            dataEncapsulator = new DataEncapsulator();
            dishesHandler = new DishesHandler();
            soldItemsHandler = new SoldItemsHandler(dataEncapsulator);
            salesHandler = new SalesHandler(dataEncapsulator);
            customerHandler = new CustomerHandler(dataEncapsulator);
            activityHandler = new ActivityHandler(dataEncapsulator);
        }

        public Restaurateur GetDatabase()
        {
            return dataEncapsulator.DB;
        }

        public SalesHandler GetSalesHandler()
        {
            return salesHandler;
        }

        public DishesHandler GetDishesHandler()
        {
            try
            {
                return serializer.DeSerialize<DishesHandler>();
            }
            catch
            {
                return new DishesHandler();
            }
        }

        public CustomerHandler GetCustomerHandler()
        {
            return customerHandler;
        }

        public ActivityHandler GetActivityHandler()
        {
            return activityHandler;
        }

        public SoldItemsHandler GetSoldItemsHandler()
        {
            return soldItemsHandler;
        }


    }
}
